import {
  Controller,
  Get,
  Post,
  Body,
  Req,
  Query,
} from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';

import { PointService } from './point.service';
import { CreatePointDto } from './dto/point.dto';
import { AdminPointPageReqDto } from './dto/admin-point.dto';

@ApiTags('小程序/积分')
@Controller('app/point')
export class PointController {
  constructor(private readonly pointService: PointService) {}

  /**
   * 添加积分
   */
  @Post()
  async create(@Req() req: Request, @Body() data: CreatePointDto) {
    await this.pointService.createWithUserAddPoint(req.user.userId, data);
  }

  /**
   * 积分列表
   */
  @Get()
  pointList(@Query() query: AdminPointPageReqDto) {
    return this.pointService.findAllForPage(query);
  }
}
